using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Text;
using System.Data.Common;

namespace CUSTOMS.Modules.HS.Components
{
    public class Chapter
    {
        public string GetName(string chapter)
        {
            string query = string.Format("SELECT [Name] FROM t_HS_Chapters WHERE ID = {0} ORDER BY ID", chapter);
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(query);
            IDataReader reader = db.ExecuteReader(dbCommand);
            string result = string.Empty;
            if (reader.Read())
            {
                result = reader[0].ToString();
            }
            reader.Close();
            dbCommand.Connection.Close();
            return result;
        }

        public DataSet SelectBy_SectionID(string sectionID)
        {
            string query = string.Format("SELECT * FROM t_HS_Chapters WHERE SectionID = '{0}' ORDER BY ID", sectionID);
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(query);
            return db.ExecuteDataSet(dbCommand);
        }
    }
}
